home *** CD-ROM | disk | FTP | other *** search
- #ifndef H_OOFRW
- #define H_OOFRW
- // COPYRIGHT 1994 A.D. Software, All rights reserved
-
- // report-writer layer of OOFILE database
-
- // NOTE inline definitions included at end of this header file
-
- #include "oof2.hpp"
- #include "oofview.hpp"
-
- class dbRepColWidths : public OOF_ExpandableLongArray {
- public:
- // construction
- dbRepColWidths (const unsigned int defColWidth=20) :
- OOF_ExpandableLongArray(defColWidth) {};
- };
-
-
- class dbRepPageBreak : public OOF_ExpandableLongArray {
- public:
- // construction
- dbRepPageBreak (const unsigned int breakPos=0xFFFF) :
- OOF_ExpandableLongArray(breakPos) {};
- };
-
-
- class dbRepOverRun : public dbClass{
- public:
- dbRepOverRun() :
- OverRun(0),
- DeleteMe(0) {};
- ~dbRepOverRun() {};
-
- char* OverRun;
- char* DeleteMe;
-
- private:
- };
-
-
- class dbRepLine : public dbClass {
- public:
- dbRepLine() :
- mLine(0) {};
- ~dbRepLine();
- private:
- dbRepLine(dbRepLine& rhs) { assert(0); };
- void operator=(const dbRepLine& rhs) { assert(0); };
-
- public:
-
- void prepare();
- void clear();
- void drawNCharsAt(unsigned int hPos, char* theChars, unsigned int len);
- void fillNCharsAt(unsigned int hPos, char theChar, unsigned int len);
- void drawToStream(unsigned int hPos, unsigned int len, ostream& os);
-
- private:
- char *mLine; // owned // for drawing onto
- static unsigned int mWidth; // size of horizontal line - given to us by dbRepPage
-
- friend class dbRep;
- };
-
-
- class dbRepSizer : public dbClass {
- public:
- // construction
- dbRepSizer (const OOF_String& reportTitle,
- const unsigned int pageHeight=70,
- const unsigned int pageWidth=80,
- const unsigned int leftMargin=6,
- const unsigned int rightMargin=6,
- const unsigned int topMargin=1,
- const unsigned int bottomMargin=1,
- const unsigned int colSepWidth=2,
- const unsigned int blockVertSep=1
- ) :
- mReportTitle(reportTitle),
- mPageHeight(pageHeight),
- mPageWidth(pageWidth),
- mLeftMargin(leftMargin),
- mRightMargin(rightMargin),
- mTopMargin(topMargin),
- mBottomMargin(bottomMargin),
- mColSepWidth(colSepWidth),
- mBlockVertSep(blockVertSep) {};
-
- dbRepSizer (const char * reportTitle="",
- const unsigned int pageHeight=70,
- const unsigned int pageWidth=80,
- const unsigned int leftMargin=6,
- const unsigned int rightMargin=6,
- const unsigned int topMargin=1,
- const unsigned int bottomMargin=1,
- const unsigned int colSepWidth=2,
- const unsigned int blockVertSep=1
- ) :
- mReportTitle(reportTitle),
- mPageHeight(pageHeight),
- mPageWidth(pageWidth),
- mLeftMargin(leftMargin),
- mRightMargin(rightMargin),
- mTopMargin(topMargin),
- mBottomMargin(bottomMargin),
- mColSepWidth(colSepWidth),
- mBlockVertSep(blockVertSep) {};
-
- // setters for use in simulating keyword arguments
- // eg dbRep( dbRepSizer("Andy's Report").pageHeight(80).DefColWidth(12) );
-
- dbRepSizer& title(const OOF_String&);
- dbRepSizer& title(const char*);
- dbRepSizer& pageHeight(const unsigned int);
- dbRepSizer& pageWidth(const unsigned int);
- dbRepSizer& leftMargin(const unsigned int);
- dbRepSizer& rightMargin(const unsigned int);
- dbRepSizer& topMargin(const unsigned int);
- dbRepSizer& bottomMargin(const unsigned int);
- dbRepSizer& colSepWidth(const unsigned int);
- dbRepSizer& blockVertSep(const unsigned int);
-
- // presentation
-
- private:
- OOF_String mReportTitle;
- unsigned int mPageHeight, mPageWidth, mLeftMargin, mRightMargin, mTopMargin, mBottomMargin;
- unsigned int mColSepWidth; // whitespace between columns
- unsigned int mBlockVertSep; // whitespace between records on columnar and blocks on pagewise
-
- friend class dbRep;
- friend class dbRepPage;
- };
-
-
- class dbRepPage : public dbClass {
- public:
- dbRepPage();
- ~dbRepPage();
- private:
- dbRepPage(dbRepPage& rhs) { assert(0); };
- void operator=(const dbRepPage& rhs) { assert(0); };
-
- public:
- void draw(dbRepSizer Sizer, ostream& os);
- void clearLines(unsigned int start, unsigned int end);
- void endPage(ostream& os);
-
- private:
- dbRepLine* mPageMap; // array of horizontal bands // owned
- unsigned int mWidth; // width of valid lines
- unsigned int mNumLines; // number of prinatble lines
- unsigned int mBodyStart; // position of data area under header
- // to save redrawing the header
- unsigned int mNumPages; // number of physical pages
- unsigned int* mFieldPos; // starting position of each field // owned
- // within each dbRepLine
- dbRepPageBreak mPageBreak; // starting position of each new page
- // within each dbRepLine
- unsigned int* mPageStart; // starting Row on page below Header // owned
-
- friend class dbRep;
- };
-
- class dbRep : public dbClass {
- public:
- enum ReportStyles {pageWise, columnar};
- // construction
- dbRep(const dbRepSizer& sizer, const dbView& fields, const ReportStyles style=columnar) :
- mSizer(sizer),
- mFields(fields),
- mReportStyle(style),
- mPage() {};
-
- dbRep(const dbRepSizer& sizer, dbRepColWidths colWidths, const dbView& fields, const ReportStyles style=columnar) :
- mSizer(sizer),
- mColWidths(colWidths),
- mFields(fields),
- mReportStyle(style),
- mPage() {};
-
- void setStyle(const ReportStyles);
-
- // presentation
- void formatForCharStream(); // may be others later
- unsigned int drawWrappedChars(unsigned int line,unsigned int hPos,unsigned int width,char **theString);
- void drawColumnar(ostream&);
- void drawPageWise(ostream&);
- void drawHeader(ostream&);
- void draw(ostream&);
- void dumpFieldList(ostream&);
- void extract(ostream&);
- char *copyStr(char *theString);
-
- private:
- dbRepSizer mSizer;
- dbRepColWidths mColWidths;
- dbView mFields;
- ReportStyles mReportStyle;
- dbRepPage mPage;
- };
-
- // include inline definitions
- #include "oofrw.inl"
-
- #endif